package com.android.kotlincoroutinemvvmdemo.view
import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.Path
import android.util.AttributeSet
import com.android.kotlincoroutinemvvmdemo.R

/*
* NetHotSpotView
* */
class NetHotSpotView @JvmOverloads constructor(
    context: Context,
    attributeSet: AttributeSet? = null
) : BaseView(context, attributeSet) {

    private val mPaint0 by lazy {
        Paint().apply {
            isAntiAlias = true
            isDither = true
            strokeCap = Paint.Cap.ROUND
            strokeWidth = context.resources.getDimension(R.dimen.dp_2)
            color = context.resources.getColor(R.color.color_0BABF3)
            style = Paint.Style.STROKE
        }
    }

    private val mPaint1 by lazy {
        Paint().apply {
            isAntiAlias = true
            isDither = true
            color = context.resources.getColor(R.color.color_0BABF3)
            style = Paint.Style.FILL
        }
    }

    override fun onDraw(canvas: Canvas?) {
        super.onDraw(canvas)
        setBackgroundColor(context.resources.getColor(R.color.color_F3F3F3))
        canvas?.apply {
            val cx = mWidth.toFloat() / 2
            val cy = mHeight.toFloat() / 2
            translate(cx, cy)
            drawCircle(0F, 0F, cx / 12, mPaint1)
            drawArc(
                -cx * 5 / 12,
                -cy * 5 / 12,
                cx * 5 / 12,
                cy * 5 / 12,
                135F,
                270F,
                false,
                mPaint0
            )
            drawArc(
                -cx / 4,
                -cy  / 4,
                cx / 4,
                cy / 4,
                135F,
                270F,
                false,
                mPaint0
            )
        }
    }
}